
import 'package:flutter_ahj_app/app/HttpRequest.dart';
import 'package:flutter_ahj_app/app/selectkaihuhang/bean/KaiHuHangBean.dart';
import 'package:flutter_ahj_app/base/basewidget/model/BaseModel.dart';
import 'package:rxdart/rxdart.dart';



class KaiHuHangModel extends BaseModel {
  BehaviorSubject<KaiHuHangBean> kaiHuHangSubject;

  Stream<KaiHuHangBean> get dataStream => kaiHuHangSubject.stream;

  getData(String bankName,String city,String province) {
    kaiHuHangSubject = BehaviorSubject();
    var data = {
      'bankName': bankName,
      'city':province ,
      'province': city,
    };
    HttpRequest.getKaihuhang(data).listen((request) {
      KaiHuHangBean kaiHuHangEntity = KaiHuHangBean.fromJson(request);
      kaiHuHangSubject.add(kaiHuHangEntity);
    }, onError: (e) {
      //请求异常等
      kaiHuHangSubject.add(null);
      errorData.add(e);
    });
  }

  @override
  void dispose() {
    super.dispose();
    if (kaiHuHangSubject != null) kaiHuHangSubject.close();
  }
}
